package com.wuzuqing.android.eightdiagrams.term;

import java.util.*;

/**
 * 八字
 */
public class EightChar {
    public static String[] MONTH_ZHI = new String[]{"", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥", "子", "丑"};
    public static String[] CHANG_SHENG = new String[]{"长生", "沐浴", "冠带", "临官", "帝旺", "衰", "病", "死", "墓", "绝", "胎", "养"};
    public static Map<String, Integer> CHANG_SHENG_OFFSET = new HashMap<>();

    Lunar lunar;

    static {
        CHANG_SHENG_OFFSET.put("甲", 1);
        CHANG_SHENG_OFFSET.put("丙", 10);
        CHANG_SHENG_OFFSET.put("戊", 10);
        CHANG_SHENG_OFFSET.put("庚", 7);
        CHANG_SHENG_OFFSET.put("壬", 4);
        CHANG_SHENG_OFFSET.put("乙", 6);
        CHANG_SHENG_OFFSET.put("丁", 9);
        CHANG_SHENG_OFFSET.put("己", 9);
        CHANG_SHENG_OFFSET.put("辛", 0);
        CHANG_SHENG_OFFSET.put("癸", 3);
    }

    public int sect = 2;

    public EightChar(Lunar lunar) {
        this.lunar = lunar;
    }

    public static EightChar fromLunar(Lunar lunar) {
        return new EightChar(lunar);
    }


    public void setSect(int sect) {
        this.sect = (1 == sect) ? 1 : 2;
    }

    public int getSect() {
        return this.sect;
    }

    public int getDayGanIndex() {
        return 2 == this.sect ? this.lunar.getDayGanIndexExact2() : this.lunar.getDayGanIndexExact();
    }

    public int getDayZhiIndex() {
        return 2 == this.sect ? this.lunar.getDayZhiIndexExact2() : this.lunar.getDayZhiIndexExact();
    }

    public String getYear() {
        return this.lunar.getYearInGanZhiExact();
    }

    public String getYearGan() {
        return this.lunar.getYearGanExact();
    }

    public String getYearZhi() {
        return this.lunar.getYearZhiExact();
    }

    public String[] getYearHideGan() {
        return LunarUtil.ZHI_HIDE_GAN.get(this.getYearZhi());
    }


    public String getYearWuXing() {
        return LunarUtil.WU_XING_GAN.get(this.getYearGan()) + LunarUtil.WU_XING_ZHI.get(this.getYearZhi());
    }

    public String getYearNaYin() {
        return LunarUtil.NAYIN.get(this.getYear());
    }

    public String getYearShiShenGan() {
        return LunarUtil.SHI_SHEN_GAN.get(this.getDayGan() + this.getYearGan());
    }

    public List<String> getYearShiShenZhi() {
        String dayGan = this.getDayGan();
        String zhi = this.getYearZhi();
        String[] hideGan = LunarUtil.ZHI_HIDE_GAN.get(zhi);
        List<String> l = new ArrayList<>();
        for (int i = 0, j = hideGan.length; i < j; i++) {
            l.add(LunarUtil.SHI_SHEN_ZHI.get(dayGan + zhi + hideGan[i]));
        }
        return l;
    }

    public String _getDiShi(int zhiIndex) {
        int offset = CHANG_SHENG_OFFSET.get(this.getDayGan());
        int index = offset + (this.getDayGanIndex() % 2 == 0 ? zhiIndex : -zhiIndex);
        if (index >= 12) {
            index -= 12;
        }
        if (index < 0) {
            index += 12;
        }
        return EightChar.CHANG_SHENG[index];
    }

    public String getYearDiShi() {
        return this._getDiShi(this.lunar.getYearZhiIndexExact());
    }

    public String getYearXun() {
        return this.lunar.getYearXunExact();
    }

    public String getYearXunKong() {
        return this.lunar.getYearXunKongExact();
    }

    public String getMonth() {
        return this.lunar.getMonthInGanZhiExact();
    }

    public String getMonthGan() {
        return this.lunar.getMonthGanExact();
    }

    public String getMonthZhi() {
        return this.lunar.getMonthZhiExact();
    }

    public String[] getMonthHideGan() {
        return LunarUtil.ZHI_HIDE_GAN.get(this.getMonthZhi());
    }

    public String getMonthWuXing() {
        return LunarUtil.WU_XING_GAN.get(this.getMonthGan()) + LunarUtil.WU_XING_ZHI.get(this.getMonthZhi());
    }

    public String getMonthNaYin() {
        return LunarUtil.NAYIN.get(this.getMonth());
    }

    public String getMonthShiShenGan() {
        return LunarUtil.SHI_SHEN_GAN.get(this.getDayGan() + this.getMonthGan());
    }

    public List<String> getMonthShiShenZhi() {
        String dayGan = this.getDayGan();
        String zhi = this.getMonthZhi();
        String[] hideGan = LunarUtil.ZHI_HIDE_GAN.get(zhi);
        List<String> l = new ArrayList<>();
        for (int i = 0, j = hideGan.length; i < j; i++) {
            l.add(LunarUtil.SHI_SHEN_ZHI.get(dayGan + zhi + hideGan[i]));
        }
        return l;
    }

    public String getMonthDiShi() {
        return this._getDiShi(this.lunar.getMonthZhiIndexExact());
    }

    public String getMonthXun() {
        return this.lunar.getMonthXunExact();
    }

    public String getMonthXunKong() {
        return this.lunar.getMonthXunKongExact();
    }

    public String getDay() {
        return 2 == this.sect ? this.lunar.getDayInGanZhiExact2() : this.lunar.getDayInGanZhiExact();
    }

    public String getDayGan() {
        return 2 == this.sect ? this.lunar.getDayGanExact2() : this.lunar.getDayGanExact();
    }

    public String getDayZhi() {
        return 2 == this.sect ? this.lunar.getDayZhiExact2() : this.lunar.getDayZhiExact();
    }

    public String[] getDayHideGan() {
        return LunarUtil.ZHI_HIDE_GAN.get(this.getDayZhi());
    }

    public String getDayWuXing() {
        return LunarUtil.WU_XING_GAN.get(this.getDayGan()) + LunarUtil.WU_XING_ZHI.get(this.getDayZhi());
    }

    public String getDayNaYin() {
        return LunarUtil.NAYIN.get(this.getDay());
    }

    public String getDayShiShenGan() {
        return "日主";
    }

    public List<String> getDayShiShenZhi() {
        String dayGan = this.getDayGan();
        String zhi = this.getDayZhi();
        String[] hideGan = LunarUtil.ZHI_HIDE_GAN.get(zhi);
        List<String> l = new ArrayList<>();
        for (int i = 0, j = hideGan.length; i < j; i++) {
            l.add(LunarUtil.SHI_SHEN_ZHI.get(dayGan + zhi + hideGan[i]));
        }
        return l;
    }

    public String getDayDiShi() {
        return this._getDiShi(this.getDayZhiIndex());
    }

    public String getDayXun() {
        return 2 == this.sect ? this.lunar.getDayXunExact2() : this.lunar.getDayXunExact();
    }

    public String getDayXunKong() {
        return 2 == this.sect ? this.lunar.getDayXunKongExact2() : this.lunar.getDayXunKongExact();
    }

    public String getTime() {
        return this.lunar.getTimeInGanZhi();
    }

    public String getTimeGan() {
        return this.lunar.getTimeGan();
    }

    public String getTimeZhi() {
        return this.lunar.getTimeZhi();
    }

    public String[] getTimeHideGan() {
        return LunarUtil.ZHI_HIDE_GAN.get(this.getTimeZhi());
    }

    public String getTimeWuXing() {
        return LunarUtil.WU_XING_GAN.get(this.getTimeGan()) + LunarUtil.WU_XING_ZHI.get(this.getTimeZhi());
    }

    public String getTimeNaYin() {
        return LunarUtil.NAYIN.get(this.getTime());
    }

    public String getTimeShiShenGan() {
        return LunarUtil.SHI_SHEN_GAN.get(this.getDayGan() + this.getTimeGan());
    }

    public List<String> getTimeShiShenZhi() {
        String dayGan = this.getDayGan();
        String zhi = this.getTimeZhi();
        String[] hideGan = LunarUtil.ZHI_HIDE_GAN.get(zhi);
        List<String> l = new ArrayList<>();
        for (int i = 0, j = hideGan.length; i < j; i++) {
            l.add(LunarUtil.SHI_SHEN_ZHI.get(dayGan + zhi + hideGan[i]));
        }
        return l;
    }

    public String getTimeDiShi() {
        return this._getDiShi(this.lunar.getTimeZhiIndex());
    }

    public String getTimeXun() {
        return this.lunar.getTimeXun();
    }

    public String getTimeXunKong() {
        return this.lunar.getTimeXunKong();
    }

    public String getTaiYuan() {
        int ganIndex = this.lunar.getMonthGanIndexExact() + 1;
        if (ganIndex >= 10) {
            ganIndex -= 10;
        }
        int zhiIndex = this.lunar.getMonthZhiIndexExact() + 3;
        if (zhiIndex >= 12) {
            zhiIndex -= 12;
        }
        return LunarUtil.GAN[ganIndex + 1] + LunarUtil.ZHI[zhiIndex + 1];
    }

    public String getTaiYuanNaYin() {
        return LunarUtil.NAYIN.get(this.getTaiYuan());
    }

    public String getMingGong() {
        int monthZhiIndex = 0;
        int timeZhiIndex = 0;
        for (int i = 0, j = EightChar.MONTH_ZHI.length; i < j; i++) {
            String zhi = EightChar.MONTH_ZHI[i];
            if (Objects.equals(lunar.getMonthZhiExact(), zhi)) {
                monthZhiIndex = i;
            }
            if (Objects.equals(lunar.getTimeZhi(), zhi)) {
                timeZhiIndex = i;
            }
        }
        int zhiIndex = 26 - (monthZhiIndex + timeZhiIndex);
        if (zhiIndex > 12) {
            zhiIndex -= 12;
        }
        int jiaZiIndex = LunarUtil.getJiaZiIndex(lunar.getMonthInGanZhiExact()) - (monthZhiIndex - zhiIndex);
        if (jiaZiIndex >= 60) {
            jiaZiIndex -= 60;
        }
        if (jiaZiIndex < 0) {
            jiaZiIndex += 60;
        }
        return LunarUtil.JIA_ZI[jiaZiIndex];
    }

    public String getMingGongNaYin() {
        return LunarUtil.NAYIN.get(this.getMingGong());
    }

    public String getShenGong() {
        int monthZhiIndex = 0;
        int timeZhiIndex = 0;
        for (int i = 0, j = EightChar.MONTH_ZHI.length; i < j; i++) {
            String zhi = EightChar.MONTH_ZHI[i];
            if (Objects.equals(lunar.getMonthZhiExact(), zhi)) {
                monthZhiIndex = i;
            }
            if (Objects.equals(lunar.getTimeZhi(), zhi)) {
                timeZhiIndex = i;
            }
        }
        int zhiIndex = (2 + (monthZhiIndex + timeZhiIndex)) % 12;
        int jiaZiIndex = LunarUtil.getJiaZiIndex(lunar.getMonthInGanZhiExact()) - (monthZhiIndex - zhiIndex);
        if (jiaZiIndex >= 60) {
            jiaZiIndex -= 60;
        }
        if (jiaZiIndex < 0) {
            jiaZiIndex += 60;
        }
        return LunarUtil.JIA_ZI[jiaZiIndex];
    }

    public String getShenGongNaYin() {
        return LunarUtil.NAYIN.get(this.getShenGong());
    }

    public Lunar getLunar() {
        return this.lunar;
    }

    private TotalYun yun;

    public TotalYun getYun(int gender) {
        if (yun != null) {
            return yun;
        }

        Lunar lunar = this.getLunar();
        boolean yang = 0 == lunar.getYearGanIndexExact() % 2;
        boolean man = 1 == gender;
        boolean forward = (yang && man) || (!yang && !man);
        StartYun startYun = StartYun.gen(lunar, forward);
        yun = new TotalYun(gender, startYun.year, startYun.month, startYun.day, forward, lunar);
        return yun;
    }


    public static class TotalYun {
        public int gender;
        public int startYear;
        public int startMonth;
        public int startDay;
        public boolean forward;
        public Lunar lunar;

        public TotalYun(int gender, int startYear, int startMonth, int startDay, boolean forward, Lunar lunar) {
            this.gender = gender;
            this.startYear = startYear;
            this.startMonth = startMonth;
            this.startDay = startDay;
            this.forward = forward;
            this.lunar = lunar;
        }

        public int getGender() {
            return gender;
        }

        public void setGender(int gender) {
            this.gender = gender;
        }

        public int getStartYear() {
            return startYear;
        }

        public void setStartYear(int startYear) {
            this.startYear = startYear;
        }

        public int getStartMonth() {
            return startMonth;
        }

        public void setStartMonth(int startMonth) {
            this.startMonth = startMonth;
        }

        public int getStartDay() {
            return startDay;
        }

        public void setStartDay(int startDay) {
            this.startDay = startDay;
        }

        public boolean isForward() {
            return forward;
        }

        public void setForward(boolean forward) {
            this.forward = forward;
        }

        public Lunar getLunar() {
            return lunar;
        }

        public void setLunar(Lunar lunar) {
            this.lunar = lunar;
        }

        public Solar getStartSolar() {
            Solar birth = this.lunar.getSolar();
            ExactDate c = birth.getCalendar();
            c.setFullYear(birth.getYear() + this.startYear);
            c.setMonth(birth.getMonth() - 1 + this.startMonth);
            c.setDate(birth.getDay() + this.startDay);
            return Solar.fromDate(c);
        }

        public List<DaYun> getDaYun(Integer n) {
            if (n == null) {
                n = 10;
            }
            List<DaYun> l = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                l.add(DaYun.buildDaYun(this, i));
            }
            return l;
        }

        @Override
        public String toString() {
            return "TotalYun{" +
                    "gender=" + gender +
                    ", startYear=" + startYear +
                    ", startMonth=" + startMonth +
                    ", startDay=" + startDay +
                    ", forward=" + forward +
                    '}';
        }
    }

    public static class DaYun {
        public int startYear;
        public int endYear;
        public int startAge;
        public int endAge;
        public int index;
        public TotalYun yun;
        public Lunar lunar;

        public DaYun(int startYear, int endYear, int startAge, int endAge,
                     int index, TotalYun yun) {
            this.startYear = startYear;
            this.endYear = endYear;
            this.startAge = startAge;
            this.endAge = endAge;
            this.index = index;
            this.yun = yun;
            this.lunar = yun.getLunar();
        }

        public static DaYun buildDaYun(TotalYun yun, int index) {
            int birthYear = yun.getLunar().getSolar().getYear();
            int year = yun.getStartSolar().getYear();
            int startYear, startAge, endYear, endAge;
            if (index < 1) {
                startYear = birthYear;
                startAge = 1;
                endYear = year - 1;
                endAge = year - birthYear;
            } else {
                int add = (index - 1) * 10;
                startYear = year + add;
                startAge = startYear - birthYear + 1;
                endYear = startYear + 9;
                endAge = startAge + 9;
            }
            return new DaYun(startYear, endYear, startAge, endAge, index, yun);
        }

        public int getStartYear() {
            return startYear;
        }

        public void setStartYear(int startYear) {
            this.startYear = startYear;
        }

        public int getEndYear() {
            return endYear;
        }

        public void setEndYear(int endYear) {
            this.endYear = endYear;
        }

        public int getStartAge() {
            return startAge;
        }

        public void setStartAge(int startAge) {
            this.startAge = startAge;
        }

        public int getEndAge() {
            return endAge;
        }

        public void setEndAge(int endAge) {
            this.endAge = endAge;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public TotalYun getYun() {
            return yun;
        }

        public void setYun(TotalYun yun) {
            this.yun = yun;
        }

        public String getGanZhi() {
            if (this.index < 1) {
                return "";
            }
            int offset = LunarUtil.getJiaZiIndex(this.lunar.getMonthInGanZhiExact());
            offset += this.yun.isForward() ? this.index : -this.index;
            int size = LunarUtil.JIA_ZI.length;
            if (offset >= size) {
                offset -= size;
            }
            if (offset < 0) {
                offset += size;
            }
            return LunarUtil.JIA_ZI[offset];
        }

        public String getXun() {
            return LunarUtil.getXun(this.getGanZhi());
        }

        public String getXunKong() {
            return LunarUtil.getXunKong(this.getGanZhi());
        }
        private List<LiuNian> cacheLiuNian = new ArrayList<>();
        public List<LiuNian> getLiuNian(Integer n) {
            if (!cacheLiuNian.isEmpty()){
                return cacheLiuNian;
            }
            if (n == null) {
                n = 10;
            }
            if (this.index < 1) {
                n = this.endYear - this.startYear + 1;
            }
            List<LiuNian> l = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                l.add(LiuNian.buildLiuNian(this, i));
            }
            cacheLiuNian.addAll(l);
            return l;
        }

        public List<XiaoYun> getXiaoYun(Integer n) {
            if (n == null) {
                n = 10;
            }
            if (this.index < 1) {
                n = this.endYear - this.startYear + 1;
            }
            List<XiaoYun> l = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                l.add(XiaoYun.buildXiaoYun(this, i, this.yun.isForward()));
            }
            return l;
        }

        @Override
        public String toString() {
            return "DaYun{" +
                    "startYear=" + startYear +
                    ", endYear=" + endYear +
                    ", startAge=" + startAge +
                    ", endAge=" + endAge +
                    ", index=" + index +
                    '}';
        }
    }

    public static class XiaoYun {
        public int year;
        public int age;
        public int index;
        public DaYun daYun;
        public boolean forward;
        public Lunar lunar;

        public XiaoYun(int index, DaYun daYun, boolean forward) {
            this.year = daYun.startYear + index;
            this.age = daYun.startAge + index;
            this.index = index;
            this.daYun = daYun;
            this.forward = forward;
            this.lunar = daYun.lunar;
        }

        public static XiaoYun buildXiaoYun(DaYun daYun, int index, boolean forward) {
            return new XiaoYun(index, daYun, forward);
        }

        public int getYear() {
            return year;
        }

        public void setYear(int year) {
            this.year = year;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public DaYun getDaYun() {
            return daYun;
        }

        public void setDaYun(DaYun daYun) {
            this.daYun = daYun;
        }

        public boolean isForward() {
            return forward;
        }

        public void setForward(boolean forward) {
            this.forward = forward;
        }

        public Lunar getLunar() {
            return lunar;
        }

        public void setLunar(Lunar lunar) {
            this.lunar = lunar;
        }

        public String getGanZhi() {
            int offset = LunarUtil.getJiaZiIndex(this.lunar.getTimeInGanZhi());
            int add = this.index + 1;
            if (this.daYun.getIndex() > 0) {
                add += this.daYun.getStartAge() - 1;
            }
            offset += this.forward ? add : -add;
            int size = LunarUtil.JIA_ZI.length;
            while (offset < 0) {
                offset += size;
            }
            offset %= size;
            return LunarUtil.JIA_ZI[offset];
        }

        public String getXun() {
            return LunarUtil.getXun(this.getGanZhi());
        }

        public String getXunKong() {
            return LunarUtil.getXunKong(this.getGanZhi());
        }

        @Override
        public String toString() {
            return "XiaoYun{" +
                    "year=" + year +
                    ", age=" + age +
                    ", index=" + index +
                    ", ganzhi=" + getGanZhi() +
                    '}';
        }
    }

    public static class StartYun {
        public int year;
        private int month;
        private int day;

        public StartYun(int year, int month, int day) {
            this.year = year;
            this.month = month;
            this.day = day;
        }

        public static StartYun gen(Lunar lunar, boolean forward) {
            JieQi prev = lunar.getPrevJie();
            JieQi next = lunar.getNextJie();
            Solar current = lunar.getSolar();

            Solar start = forward ? current : prev.getSolar();
            Solar end = forward ? next.getSolar() : current;
            int endTimeZhiIndex = (end.getHour() == 23) ? 11 :
                    LunarUtil.getTimeZhiIndex(end.toYmdHms().substring(11, 16));
            int startTimeZhiIndex = (start.getHour() == 23) ? 11 :
                    LunarUtil.getTimeZhiIndex(start.toYmdHms().substring(11, 16));
            // 时辰差
            int hourDiff = endTimeZhiIndex - startTimeZhiIndex;
            ExactDate endCalendar = ExactDate.fromYmd(end.getYear(), end.getMonth(), end.getDay());
            ExactDate startCalendar = ExactDate.fromYmd(start.getYear(), start.getMonth(), start.getDay());
            // 天数差
            double dayDiff = Math.floor((endCalendar.getTime() * 1d - startCalendar.getTime()) / (1000 * 3600 * 24));
            if (hourDiff < 0) {
                hourDiff += 12;
                dayDiff--;
            }
            double monthDiff = Math.floor(hourDiff * 10d / 30);
            double month = dayDiff * 4 + monthDiff;
            double day = hourDiff * 10d - monthDiff * 30;
            double year = Math.floor(month / 12);
            month = month - year * 12;
            return new StartYun((int) year, (int) month, (int) day);
        }
    }

    public static class LiuYue {
        private int index;
        private LiuNian liuNian;

        public LiuYue(int index, LiuNian liuNian) {
            this.index = index;
            this.liuNian = liuNian;
        }

        public static LiuYue buildLiuYue(LiuNian liuNian, int index) {
            return new LiuYue(index, liuNian);
        }

        public int getIndex() {
            return index;
        }

        public LiuNian getLiuNian() {
            return liuNian;
        }

        public String getMonthInChinese() {
            return LunarUtil.MONTH[this.index + 1];
        }

        public String getGanZhi() {
            int offset = 0;
            String yearGan = liuNian.getGanZhi().substring(0, 1);
            if ("甲".equals(yearGan) || "己".equals(yearGan)) {
                offset = 2;
            } else if ("乙".equals(yearGan) || "庚".equals(yearGan)) {
                offset = 4;
            } else if ("丙".equals(yearGan) || "辛".equals(yearGan)) {
                offset = 6;
            } else if ("丁".equals(yearGan) || "壬".equals(yearGan)) {
                offset = 8;
            }
            String gan = LunarUtil.GAN[(this.index + offset) % 10 + 1];
            String zhi = LunarUtil.ZHI[(this.index + LunarUtil.BASE_MONTH_ZHI_INDEX) % 12 + 1];
            return gan + zhi;
        }

        public String getXun() {
            return LunarUtil.getXun(this.getGanZhi());
        }

        public String getXunKong() {
            return LunarUtil.getXunKong(this.getGanZhi());
        }

        @Override
        public String toString() {
            return getMonthInChinese() + " " + getGanZhi();
        }
    }

    public static class LiuNian {
        public int year;
        public int age;
        public int index;
        public DaYun daYun;
        public Lunar lunar;

        public LiuNian(int year, int age, int index, DaYun daYun) {
            this.year = year;
            this.age = age;
            this.index = index;
            this.daYun = daYun;
            this.lunar = daYun.lunar;
        }

        public static LiuNian buildLiuNian(DaYun daYun, int index) {
            return new LiuNian(daYun.getStartYear() + index,
                    daYun.getStartAge() + index, index, daYun);
        }


        public int getYear() {
            return this.year;
        }

        public int getAge() {
            return this.age;
        }

        public int getIndex() {
            return this.index;
        }

        public Lunar getLunar() {
            return this.lunar;
        }

        public String getGanZhi() {
            int offset = LunarUtil.getJiaZiIndex(this.lunar.getJieQiTable().get("立春")
                    .getLunar().getYearInGanZhiExact()) + this.index;
            if (this.daYun.getIndex() > 0) {
                offset += this.daYun.getStartAge() - 1;
            }
            offset %= LunarUtil.JIA_ZI.length;
            return LunarUtil.JIA_ZI[offset];
        }

        public String getXun() {
            return LunarUtil.getXun(this.getGanZhi());
        }

        public String getXunKong() {
            return LunarUtil.getXunKong(this.getGanZhi());
        }

        List<LiuYue> cacheLiuYue = new ArrayList<>();
        public List<LiuYue> getLiuYue() {
            if (!cacheLiuYue.isEmpty()){
                return cacheLiuYue;
            }
            List<LiuYue> l = new ArrayList<>();
            for (int i = 0; i < 12; i++) {
                l.add(LiuYue.buildLiuYue(this, i));
            }
            cacheLiuYue.addAll(l);
            return l;
        }

        @Override
        public String toString() {
            return "LiuNian{" +
                    "year=" + year +
                    ", age=" + age +
                    ", index=" + index +
                    ", 干支=" + getGanZhi() +
                    '}';
        }
    }


    @Override
    public String toString() {
        return this.getYear() + " " + this.getMonth() + " " + this.getDay() + " " + this.getTime();
    }
}
